package com.hongyun.tms.common.enums;

import lombok.Getter;

import java.util.Objects;

/**
 * 调度日志枚举
 * <p>
 * 01白班02夜班
 *
 * @author peng.li
 * @date 2024-09-12
 */
@Getter
public enum DisLogEnum {
    NORMAL("01", "白班"),
    DESTROY("02", "夜班");

    private final String code;
    private final String desc;

    DisLogEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static DisLogEnum fromCode(String code) {
        for (DisLogEnum status : DisLogEnum.values()) {
            if (Objects.equals(status.getCode(), code)) {
                return status;
            }
        }
        return null;
    }

    public static String getCodeByDesc(String desc) {
        DisLogEnum[] tugStatusEnums = values();
        for (DisLogEnum tugStatusEnum : tugStatusEnums) {
            if (tugStatusEnum.getDesc().equals(desc)) {
                return tugStatusEnum.getCode();
            }
        }
        return null;
    }
}
